{
 "metadata": {
  "signature": "sha256:d848f510a47b507adf33d760e1a0b291ae0bede226c2a0b50775320945bcc69c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "dbase\n",
      "======================================================================\n",
      "\n",
      "> **NOTE**: You may want to use [pandas](http://pandas.pydata.org/) instead of this.\n",
      "\n",
      "The [dbase.py](files/attachments/dbase/dbase.0.7.py) class, can be used to\n",
      "read/write/summarize/plot time-series data.\n",
      "\n",
      "To summarize the functionality:\n",
      "\n",
      "1. data and variable names stored in a dictionary - accessible using variable names\n",
      "2. load/save from/to csv/pickle format, including date information (shelve format to be added)\n",
      "3. plotting and descriptive statistics, with dates if provided\n",
      "4. adding/deleting variables, including trends/(seasonal)dummies\n",
      "5. selecting observations based on dates or other variable values (e.g., > 1/1/2003)\n",
      "6. copying instance data\n",
      "\n",
      "Attached also the [dbase_pydoc.txt](files/attachments/dbase/dbase_pydoc.0.2.txt) information for the class.\n",
      "\n",
      "Example Usage\n",
      "-------------\n",
      "\n",
      "To see the class in action download the file and run it (python\n",
      "dbase.py). This will create an example data file\n",
      "(./dbase\\_test\\_files/data.csv) that will be processed by the class.\n",
      "\n",
      "To import the module:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import sys\n",
      "sys.path.append('attachments/dbase')\n",
      "import dbase"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "After running the class you can load the example data using"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "data = dbase.dbase(\"attachments/dbase/data.csv\", date = 0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "In the above command '0' is the index of the column containing dates.\n",
      "\n",
      "You can plot series 'b' and 'c' in the file using"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "data.dataplot('b','c')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "![](files/attachments/dbase/ex_plot.0.1.png)\n",
      "\n",
      "You get descriptive statistics for series 'a','b', and 'c' by using"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "data.info('a','b','c')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "==============================================================================\n",
        "============================ Database information ============================\n",
        "==============================================================================\n",
        "\n",
        "file:\t\t\t\t/mnt/data/pauli/prj/scipy/SciPy-CookBook/ipython/attachments/dbase/data.csv\n",
        "# obs:\t\t\t\t100\n",
        "# variables:\t\t3\n",
        "Start date:\t\t\t08 Jan 2001\n",
        "End date:\t\t\t02 Dec 2002\n",
        "\n",
        "var\t\t\t\tmin\t\t\tmax\t\t\tmean\t\tstd.dev\t\tmiss\tlevels\n",
        "==============================================================================\n",
        "a    \t\t\t-2.56\t\t 3.35\t\t-0.08\t\t 1.08\t\t 0   \n",
        "b    \t\t\t-2.00\t\t 2.16\t\t-0.02\t\t 0.98\t\t 0   \n",
        "c    \t\t\t-1.91\t\t 2.54\t\t 0.18\t\t 0.93\t\t 0   \n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}